package quanlysach;


import java.awt.print.Book;
import java.util.ArrayList;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Documents
 */
public class BookManagement 
{
    ArrayList<Book> BookList;
    int soLuong;
    Scanner nhap = new Scanner(System.in);
    public BookManagement()
    {
        BookList = new ArrayList();
    }
    
    //them vao danh sach
    public void addBookList()
    {
       Book b = new Book();
       /*System.out.print("So luong sach can them: ");
       soLuong = nhap.nextInt();
       System.out.print("Nhap ma sach: ");
       b.setMaSach(nhap.nextLine());*/
        //Book b = new Book();
        System.out.print("Nhap so luong sach can them: ");
        soLuong = nhap.nextInt();
        for (int i = 0; i<soLuong; i++)
        {
            b.setBook(nhap.addBook());
        }
    }   
    
    //in danh sach
    public void printBookList()
    {
        Book b = new Book();
        System.out.println("----Danh sach----");
        for (int i=0; i<soLuong; i++)
        {
            System.out.println(BookList.get(i));
        }
    }
    
    //tim ma sach
    public void searchBook(String maTim)
    {
        //ArrayList<Book> tim = new ArrayList<Book>();
        System.out.print("Nhap ma can tim: ");
        maTim = nhap.nextLine();
        for(int i=0; i<BookList.size(); i++)
        {
            Book b1 = BookList.get(i);
            //if(Book.maSach == maTim)
            if(maTim.equals(b1))
            {
                System.out.print(BookList.get(i));
            }
        }
        System.out.print("Khong tim thay!");
    }

}
